package graph_viewer.animator;

import java.awt.*;
import javax.swing.*;

import java.util.*;

import graph_viewer.canvas.*;
import graph_viewer.structure.*;
import graph_viewer.util.*;
/**
 * the super interface of Animator.
 * now no public method defined.
 */

public  class Animator_Actor{//simultenaousely 
	public void do_multiple_animation( ArrayList animation_elements, Drawer_Canvas graph_canvas ){
		
		while ( true ){
			int number_of_motion = 0;

			for ( Iterator _i = animation_elements.iterator() ; _i.hasNext() ; ){
				Animator_Metrics a_m	= (Animator_Metrics)_i.next();
					
				if ( a_m == null ){
					continue;
				}
				Animator				animator	 = a_m.get_animator();

				if ( animator.do_animation( a_m, graph_canvas ) ){
					number_of_motion++;
				}				
			}

			//Debug.println( "number_of_motion=" + number_of_motion, 3 );
			if ( number_of_motion == 0 ){
				break;
			}
		}	
		//*do_non_simultenoues_multiple_animation( animation_elements, graph_canvas );
	//  
	}

	public void do_non_simultenoues_multiple_animation( ArrayList animation_elements, Drawer_Canvas graph_canvas ){
		for ( Iterator _i = animation_elements.iterator() ; _i.hasNext() ; ){
			Animator_Metrics a_m	= (Animator_Metrics)_i.next();
				
			if ( a_m == null ){
				continue;
			}
			Animator	animator	 = a_m.get_animator();
			
			while ( animator.do_animation( a_m, graph_canvas )  ){}
		}

	}

	public void do_animation( Animator_Metrics Animator_Metrics, Drawer_Canvas graph_canvas ){
		Animator				animator	 = Animator_Metrics.get_animator();
		Debug.println( "Animator_Actor.do_cluster_animation...", 3 );
		
		while ( animator.do_animation( Animator_Metrics, graph_canvas ) ){}//until animation finishes
		
		Debug.println( "Animator_Actor.do_cluster_animation Finished!", 3 );
	}

}//:~